package cn.liip.dao;

import java.util.List;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import cn.liip.beans.Student;

public class ManageDaoTest {
	static IManageDao dao;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		dao = new ManageDaoMySqlImpl();
	}

	@Test
	public void testGetAll() {
		List<Student> students = dao.getAllStudent();
		for (Student student : students) {
			System.out.println(student);
		}
	}

	@Test
	public void testAdd() {
		Student student = new Student();
		student.setName("test");
		dao.add(student);
	}

	@Test
	public void testFindOne() {
		Student student = dao.findOne("1453119933473");
		System.out.println(student);
	}

	@Test
	public void testDel() {
		dao.del("1453174217155");

	}

	@Test
	public void testUpdate() {
		Student student = dao.findOne("1453119933473");
		System.out.println(student);
		student.setAddress(student.getAddress() + "_new");
		System.out.println(student);
		int result = dao.update(student);
		Assert.assertEquals(1, result);
	}
}
